/****************************************************************************
 * 2025.9 阿桑的笔记本
 ****************************************************************************/

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using QFramework;

namespace QFramework.Example
{
    /// <summary>
    /// 归零点一开始就该赋值
    /// </summary>
	public partial class FireZeroPanel : UIElement
	{


        public SurroundingsPlanes surroundingsPlanes;

        private void Awake()
        {
            BtnClicks();

            for (int i = 0; i < inputFields.Count; i++)
            {
                // inputFields[i].text = FreePlayDataManager.Instance.gameModel.gameScence.ZeroDistances[i].ToString();

                inputFields[i].text = surroundingsPlanes.dataManager.gameScenceDatas.ZeroDistances[i].ToString();
            }
        }

		protected override void OnBeforeDestroy()
		{
		}

        public override void BtnClicks()
        {
            RemoveBtn.onClick.AddListener(
                () =>{

                    for (int i = 0; i < inputFields.Count; i++)
                    {
                        inputFields[i].text = surroundingsPlanes.dataManager.gameScenceDatas.ZeroDistances[i].ToString();
                    }

                        this.Hide();

            });

            SetBtn.onClick.AddListener(() =>
            {
                for (int i = 0; i < inputFields.Count; i++)
                {
                    if (inputFields[i].text == "" && float.Parse(inputFields[i].text) <= 0)
                    {
                        inputFields[i].text = surroundingsPlanes.dataManager.gameScenceDatas.ZeroDistances[i].ToString();
                    }
                    else
                    {
                        surroundingsPlanes.dataManager.gameScenceDatas.ZeroDistances[i]= float.Parse(inputFields[i].text);
                    }
                }
                this.Hide();
            });

            //throw new NotImplementedException();
        }
    }
}